package com.moonshineproject.parser.context
{
	public class ContextSwitchManager {
		private var switches:Object = {};
		
		function ContextSwitchManager(switches:Vector.<ContextSwitch>) {
			for each (var swtch:ContextSwitch in switches)
			{
				addSwitch(swtch);
			}
		}
		
		public function addSwitch(swtch:ContextSwitch, highPriority:Boolean = false):void
		{
			for each (var from:int in swtch.from)
			{
				if (!switches[from]) switches[from] = new Vector.<ContextSwitch>();
				
				if (highPriority) switches[from].unshift(swtch);
				else switches[from].push(swtch);
			}
		}
		
		public function getSwitches(from:int):Vector.<ContextSwitch>
		{
			return switches[from];
		}
	}
}